package com.cug.smartranch.animal.admin.controller;

import com.cug.smartranch.animal.admin.dao.entity.EnvironmentMonitoring;
import com.cug.smartranch.animal.admin.dto.req.EnvironmentMonitoringReqDTO;
import com.cug.smartranch.animal.admin.dto.resp.EnvironmentMonitoringRespDTO;
import com.cug.smartranch.animal.admin.service.EnvironmentMonitoringService;
import com.cug.smartranch.framework.result.Result;
import com.cug.smartranch.framework.web.Results;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 动物控制层
 */
@RestController
@RequiredArgsConstructor
@Tag(name = "环境监测管理")
@RequestMapping("/api/environment-admin/environment")
public class EnvironmentMonitoringController {
    private final EnvironmentMonitoringService environmentMonitoringService;

    @Operation(summary = "后端批量创建环境记录（测试使用）")
    @PostMapping("/create")
    public Result<Void> createEnvironment() {
        environmentMonitoringService.createEnvironment();
        return Results.success();
    }

    @Operation(summary = "根据开始时间和结束时间获取监测数据(开始结束时间跨度不能超过10天)")
    @GetMapping("/get")
    public Result<Map<Date, EnvironmentMonitoringRespDTO>> getEnvironment(EnvironmentMonitoringReqDTO requestParam) {
        Map<Date, EnvironmentMonitoringRespDTO> result = environmentMonitoringService.getEnvironment(requestParam);
        return Results.success(result);
    }
}
